FlyTalk.views.SearchPostView = Ext.extend(Ext.Panel, {	
	title: 'Posts',
	initComponent: function () {
		
		this.backButton = new Ext.Button({
			text: 'Back',
			ui: 'back',
			handler: this.backButtonTap,
			scope: this
		});
	
		this.postToolbar = new Ext.Toolbar({
			title: 'Thread',
			items:[
				this.backButton,
				{ xtype: 'spacer' },
			]
		});
		
		this.MixedStore = new Ext.data.JsonStore({
			model : 'MixedPostModel',
		});
		
		this.tweetList = new Ext.List({
			fullscreen: true,
			scroll: true,
			emptyText: '<div style="margin:5px;">No tweets cached.</div>',
			itemTpl : [ 
'<div id="touchpoint_container_{type}_{answered}">',
'<tpl for=".">',
    '<div class="touchpoint_data">',
    '<div class="touchpoint_icon">',
        '<img width="44" height="44" src="{image_url}"/>',
    '</div>',
    '<div class="touchpoint_content_{type}">',
        '<h3 class="touchpoint">{from_user} <!--<span class="type">{type}</span>--></h3>',
        '<p>{text}</p>',
    '</div>',
    '</div>',
    '<div class="plus_{answered}"><img src="images/post_plus.png" width="44" height="44"></div>',
    '<div class="clear"></div>',
	'<div class="tweet-details">{date}, posted in Portuguese, <!--{followed}--> {up} <img src="images/thumbsUP_postscopy.png" width="10px" /> / {down} <img src="images/thumbsDown_postscopy.png" width="10px" /> <img src="{tp}" width="10px" /></div>',
    '</div>',
'</tpl>',
'</div>'
			],
			grouped : false,
			indexBar: false,
			width: 320,
			flex:1,
		//	onItemDisclosure: true,
			store: this.MixedStore,
	
			listeners:{
				itemTap: function(dv, index, tweet, e){
					if(e.getTarget('.touchpoint_icon')){
						alert("click image");
						// need to link to public profile
					}
					else if(e.getTarget('.plus_') || e.getTarget('.plus_yes')){
						FlyTalk.views.TalkView.tweetToolbar.title = "search";
						//FlyTalk.views.SearchPostView.onMenu(index);	
					}	
				},
			},
		});	
		
      //  this.dockedItems = [this.postToolbar];
		this.items = [this.tweetList];

        FlyTalk.views.SearchPostView.superclass.initComponent.call(this);
    },

    backButtonTap: function () {
    	// link to next page
		var next = FlyTalk.views.TalkView.tweetToolbar.title; // see which page talk is on right now
		Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openNext',
            next: next,
        });
    },
    
    onMenu: function (ind) {
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openSearchMenu',
           // post: record,
            index: ind,
        });
    },

});